import Vue from 'vue'
import VueRouter from 'vue-router'
import App from './App.vue'
import AccountList from './components/AccountList.vue'
import AccountDaylist from './components/AccountDaylist.vue'
import AccountDetail from './components/AccountDetail.vue'
import AccountDetailBeforePay from './components/AccountDetailBeforePay.vue'
import AccountDetailPayok from './components/AccountDetailPayok.vue'
import CheckIn from './components/CheckIn.vue'
import Recharge from './components/Recharge.vue'
import CustomPrice from './components/CustomPrice.vue'
import Download from './components/Download.vue'
import SunnyCard from './components/SunnyCard.vue'

Vue.transition('fade', {
  enterClass: 'fadeIn',
  leaveClass: 'fadeOut'
})

Vue.use(VueRouter)

const router = new VueRouter({
  transitionOnLoad: true
})

router.map({
  // 下载页面
  '/download': {
    name: 'Download',
    component: Download
  },
  // 自定义商品价格
  '/custom-price': {
    name: 'CustomPrice',
    component: CustomPrice
  },
  // 阳光卡
  '/sunny-card': {
    name: 'SunnyCard',
    component: SunnyCard
  },
  // 签到
  '/check-in': {
    name: 'CheckIn',
    component: CheckIn
  },
  '/recharge': {
    name: 'Recharge',
    component: Recharge
  },
  // 购买平台根路由
  '/account': {
    name: 'AccountList',
    component: {
      template: '<div><router-view transition="fade" transition-mode="out-in" class="animated short"></router-view></div>'
    },
    subRoutes: {
      // 购买平台列表
      '/': {
        component: AccountList
      },
      // 购买帐号列表
      '/:pid': {
        name: 'AccountDaylist',
        component: {
          template: '<div><router-view transition="fade" transition-mode="out-in" class="animated short"></router-view></div>'
        },
        subRoutes: {
          '/': {
            component: AccountDaylist,
          },
          '/:aid': {
            name: 'AccountDetail',
            component: AccountDetail,
            subRoutes: {
              '/': {
                component: AccountDetailBeforePay
              },
              '/:randomKey': {
                name: 'AccountDetailPayok',
                component: AccountDetailPayok
              }
            }
          }
        }
      }
    }
  },

})

router.redirect({
  '*': '/account'
})

router.start(App, '#app')
